PRINT '-------------------------------------------'
PRINT 'Starting execution of PBDsk_Feeds.SQL'
PRINT '-------------------------------------------'
GO

SET QUOTED_IDENTIFIER OFF
SET ANSI_NULLS ON         -- We don't want (NULL = NULL) == TRUE
GO
SET ANSI_PADDING ON
GO
SET ANSI_NULL_DFLT_ON ON
GO




IF (NOT EXISTS (SELECT name
                FROM sysobjects
                WHERE (name = N'PBDsk_FeedChannel')
                  AND (type = 'U')))
BEGIN
	CREATE TABLE [PBDsk_FeedChannel](
		[ChannelID] [int] IDENTITY(1,1) NOT NULL,
		[Title] [varchar](1000) NOT NULL,
		[Link] [varchar](1000) NOT NULL,
		[Image] [varchar](1000) NOT NULL,
		[Description] [varchar](max) NOT NULL,
		[IsActive] [bit] NULL,
		[LastUpdBy] [varchar](25) NULL,
		[LastUpdDt] [smalldatetime] NULL
	 CONSTRAINT [PK_PBDsk_FeedChannel] PRIMARY KEY CLUSTERED 
	(
		[ChannelID] ASC
	)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
	) ON [PRIMARY]

END
GO

IF (NOT EXISTS (SELECT name
                FROM sysobjects
                WHERE (name = N'PBDsk_FeedNewsItem')
                  AND (type = 'U')))
BEGIN
		CREATE TABLE [PBDsk_FeedNewsItem](
		[NewsItemID] [int] IDENTITY(1,1) NOT NULL,
		[Title] [varchar](1000) NOT NULL,
		[Description] [varchar](max) NOT NULL,
		[Link] [varchar](1000) NOT NULL,
		[PubDate] [smalldatetime]  NULL,
		[Author] [varchar](512)  NULL,
		[IsActive] [bit] NULL,
		[LastUpdBy] [varchar](25) NULL,
		[LastUpdDt] [smalldatetime] NULL
		 CONSTRAINT [PK_PBDsk_FeedNewsItem] PRIMARY KEY CLUSTERED 
		(
			[NewsItemID] ASC
		)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
		) ON [PRIMARY]

END
GO

IF (NOT EXISTS (SELECT name
                FROM sysobjects
                WHERE (name = N'PBDsk_FeedChannelNewsItem')
                  AND (type = 'U')))
BEGIN
	CREATE TABLE [PBDsk_FeedChannelNewsItem](
		[ChannelID] [int]  NOT NULL FOREIGN KEY REFERENCES [PBDsk_FeedChannel]([ChannelID]),
		[NewsItemID] [int]  NOT NULL FOREIGN KEY REFERENCES [PBDsk_FeedNewsItem]([NewsItemID]),	
		[IsActive] [bit] NULL,
		[LastUpdBy] [varchar](25) NULL,
		[LastUpdDt] [smalldatetime] NULL
	 CONSTRAINT [PK_PBDsk_FeedChannelNewsItem] PRIMARY KEY CLUSTERED 
	(
		[ChannelID] ASC,
		[NewsItemID] ASC
	)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
	) ON [PRIMARY]

END
GO


PRINT '--------------------------------------------'
PRINT 'Completed execution of PBDsk_Feeds.SQL'
PRINT '--------------------------------------------'

